<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>
    But you should have one thing mind. |
    
    无敌小笼包</title>
  
    <link rel="shortcut icon" href="/favicon.png">
  
  <link rel="stylesheet" href="/css/style.css">
  
    <link rel="stylesheet" href="/fancybox/jquery.fancybox.min.css">
  
  <script src="/js/pace.min.js"></script>
</head>

<body>
<main class="content">
  <section class="outer">
  <article id="post-everyday" class="article article-type-post" itemscope itemprop="blogPost">

  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      But you should have one thing mind.
    </h1>
  

      </header>
    

    
      <div class="article-meta">
        <a href="/2017/03/10/everyday/" class="article-date">
  <time datetime="2017-03-10T10:09:05.000Z" itemprop="datePublished">2017-03-10</time>
</a>
        
  <div class="article-category">
    <a class="article-category-link" href="/categories/php/">php</a>
  </div>

      </div>
    

    <div class="article-entry" itemprop="articleBody">
      
      
      
        <p>随时更新一下值得记忆的一些踏过的坑</p>
<a id="more"></a>
<h3 id="Mac-git-大小写问题"><a href="#Mac-git-大小写问题" class="headerlink" title="Mac git 大小写问题"></a>Mac git 大小写问题</h3><p>由于 Mac 下文件名大小写不敏感，造成 git 下如果改了名字，譬如小写改大些，推送到 linux 服务器的时候会没有效果，Github 上的也是小写。<br>所以，如果在 Mac 上改文件名，需要用下面的命令</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">$ git mv --force myfile MyFile</div><div class="line"></div><div class="line"><span class="comment">#修改git配置，不忽略大小写</span></div><div class="line">git config core.ignorecase <span class="literal">false</span></div></pre></td></tr></table></figure>
<h3 id="删除git-远程的分支"><a href="#删除git-远程的分支" class="headerlink" title="删除git 远程的分支"></a>删除git 远程的分支</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ git push --delete origin branch_name</div></pre></td></tr></table></figure>
<h3 id="推送出现一些同步的错误，可以加个-f"><a href="#推送出现一些同步的错误，可以加个-f" class="headerlink" title="推送出现一些同步的错误，可以加个-f"></a>推送出现一些同步的错误，可以加个-f</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ git push origin dev <span class="_">-f</span></div></pre></td></tr></table></figure>
<h3 id="修改crontab-的编辑器"><a href="#修改crontab-的编辑器" class="headerlink" title="修改crontab 的编辑器"></a>修改crontab 的编辑器</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">export</span> EDITOR=/usr/bin/vim <span class="comment"># crontab -e</span></div></pre></td></tr></table></figure>
<h3 id="redis-MONITOR-监控redis的所有的被执行的命令"><a href="#redis-MONITOR-监控redis的所有的被执行的命令" class="headerlink" title="redis MONITOR 监控redis的所有的被执行的命令"></a>redis MONITOR 监控redis的所有的被执行的命令</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">//在程序之外用管道监控某一个命令。</div><div class="line">redis-cli -h 172.16.71.70 -p 6379 MONITOR|grep medal:rank:9</div><div class="line">1472647383.968024 [0 172.16.71.67:48460] <span class="string">"ZINCRBY"</span> <span class="string">"medal:rank:9"</span> <span class="string">"1.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647384.560867 [0 172.16.71.69:60301] <span class="string">"ZADD"</span> <span class="string">"medal:rank:9"</span> <span class="string">"108.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647384.561215 [0 172.16.71.69:60301] <span class="string">"ZCARD"</span> <span class="string">"medal:rank:9"</span></div><div class="line">1472647440.527100 [0 172.16.71.67:48566] <span class="string">"ZINCRBY"</span> <span class="string">"medal:rank:9"</span> <span class="string">"1.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647440.811201 [0 172.16.71.69:60301] <span class="string">"ZADD"</span> <span class="string">"medal:rank:9"</span> <span class="string">"109.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647440.811598 [0 172.16.71.69:60301] <span class="string">"ZCARD"</span> <span class="string">"medal:rank:9"</span></div><div class="line">1472647456.269238 [0 172.16.71.67:48586] <span class="string">"ZINCRBY"</span> <span class="string">"medal:rank:9"</span> <span class="string">"1.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647457.091923 [0 172.16.71.69:60301] <span class="string">"ZADD"</span> <span class="string">"medal:rank:9"</span> <span class="string">"110.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647457.092253 [0 172.16.71.69:60301] <span class="string">"ZCARD"</span> <span class="string">"medal:rank:9"</span></div><div class="line">1472647457.523799 [0 172.16.71.67:48593] <span class="string">"ZINCRBY"</span> <span class="string">"medal:rank:9"</span> <span class="string">"1.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647458.364086 [0 172.16.71.69:60301] <span class="string">"ZADD"</span> <span class="string">"medal:rank:9"</span> <span class="string">"111.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647458.364470 [0 172.16.71.69:60301] <span class="string">"ZCARD"</span> <span class="string">"medal:rank:9"</span></div><div class="line">1472647473.428126 [0 172.16.71.67:48605] <span class="string">"ZCARD"</span> <span class="string">"medal:rank:9"</span></div><div class="line">1472647473.451694 [0 172.16.71.67:48605] <span class="string">"ZCARD"</span> <span class="string">"medal:rank:9"</span></div><div class="line">1472647473.451863 [0 172.16.71.67:48605] <span class="string">"ZREVRANK"</span> <span class="string">"medal:rank:9"</span> <span class="string">"12436136"</span></div><div class="line">1472647473.452154 [0 172.16.71.67:48605] <span class="string">"ZREVRANGE"</span> <span class="string">"medal:rank:9"</span> <span class="string">"0"</span> <span class="string">"9"</span></div><div class="line">1472647516.470815 [0 172.16.71.67:48690] <span class="string">"ZINCRBY"</span> <span class="string">"medal:rank:9"</span> <span class="string">"1.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647516.663979 [0 172.16.71.69:60301] <span class="string">"ZADD"</span> <span class="string">"medal:rank:9"</span> <span class="string">"112.0000000000000000"</span> <span class="string">"12436136"</span></div><div class="line">1472647516.664325 [0 172.16.71.69:60301] <span class="string">"ZCARD"</span> <span class="string">"medal:rank:9"</span></div></pre></td></tr></table></figure>
<h3 id="监控文件的实时数据-tail-f"><a href="#监控文件的实时数据-tail-f" class="headerlink" title="监控文件的实时数据 tail -f"></a>监控文件的实时数据 tail -f</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">//当文件有数据写入时，能实时的输出</div><div class="line">tail -f app.log</div><div class="line">logs tail -f app.log</div><div class="line">[2016-08-25 18:57:37] slim-app.INFO: Slim-Skeleton &apos;/&apos; route [] &#123;&quot;uid&quot;:&quot;9aeff67&quot;&#125;</div><div class="line">[2016-08-25 18:57:37] slim-app.INFO: Slim-Skeleton &apos;/&apos; route [] &#123;&quot;uid&quot;:&quot;a117fed&quot;&#125;</div><div class="line">[2016-08-25 18:57:42] slim-app.INFO: Slim-Skeleton &apos;/&apos; route [] &#123;&quot;uid&quot;:&quot;c6edb36&quot;&#125;</div><div class="line">[2016-08-25 18:57:42] slim-app.INFO: Slim-Skeleton &apos;/&apos; route [] &#123;&quot;uid&quot;:&quot;a29a035&quot;&#125;</div><div class="line">[2016-08-25 19:02:00] slim-app.INFO: Slim-Skeleton &apos;/&apos; route [] &#123;&quot;uid&quot;:&quot;a11dfb4&quot;&#125;</div><div class="line">[2016-08-25 19:02:59] slim-app.INFO: Slim-Skeleton &apos;/&apos; route [] &#123;&quot;uid&quot;:&quot;95e2320&quot;&#125;</div><div class="line">[2016-08-25 19:03:07] slim-app.INFO: Slim-Skeleton &apos;/&apos; route [] &#123;&quot;uid&quot;:&quot;3a5aa35&quot;&#125;</div></pre></td></tr></table></figure>
<h3 id="set-error-handler-PHP中用来捕获自定义的错误信息"><a href="#set-error-handler-PHP中用来捕获自定义的错误信息" class="headerlink" title="set_error_handler PHP中用来捕获自定义的错误信息"></a>set_error_handler PHP中用来捕获自定义的错误信息</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">public <span class="keyword">function</span> <span class="function"><span class="title">aaa</span></span>()</div><div class="line">&#123;</div><div class="line">    <span class="keyword">function</span> customError(<span class="variable">$errno</span>, <span class="variable">$errstr</span>, <span class="variable">$errfile</span>, <span class="variable">$errline</span>)</div><div class="line">    &#123;</div><div class="line">        <span class="built_in">echo</span> <span class="string">"&lt;b&gt;Custom error:&lt;/b&gt; [<span class="variable">$errno</span>] <span class="variable">$errstr</span>&lt;br /&gt;"</span>;</div><div class="line">        <span class="built_in">echo</span> <span class="string">" Error on line <span class="variable">$errline</span> in <span class="variable">$errfile</span>&lt;br /&gt;"</span>;</div><div class="line">        <span class="built_in">echo</span> <span class="string">"Ending Script"</span>;</div><div class="line">        die();</div><div class="line">    &#125;</div><div class="line">    //<span class="built_in">set</span> error handler， 第二个参数是可以设置需要捕获的错误类型</div><div class="line">    set_error_handler(<span class="string">"customError"</span>, E_ALL | E_WARNING);</div><div class="line">    //<span class="variable">$a</span> 没定义，应该会有一个错误：</div><div class="line">    var_dump(<span class="variable">$a</span>);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>看下打印输出，就能按照我们的方式输出打印错误：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;b&gt;Custom error:&lt;/b&gt; [8] Undefined variable: a&lt;br /&gt; Error on line 169 in /data/app/live/include/controller/TmpCtrl.php&lt;br /&gt;Ending Script%</div></pre></td></tr></table></figure>
<h3 id="php-cli-命令"><a href="#php-cli-命令" class="headerlink" title="php cli 命令"></a>php cli 命令</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div></pre></td><td class="code"><pre><div class="line">php -i</div><div class="line">查看phpinfo</div><div class="line">php -v</div><div class="line">显示PHP版本</div><div class="line">php -m</div><div class="line">查看PHP安装了哪些扩展模块，可修改php.ini添加删除扩展模块。</div><div class="line">编译PHP时内置的扩展，无法通过修改php.ini删除</div><div class="line">php -S</div><div class="line">启动一个内置的Web服务器，用于开发环境内进行程序的调试。</div><div class="line">php -S 0.0.0.0:9000</div><div class="line">内置的Web服务器是一个全功能的Http服务器，在开发模式下可以取代apache,nginx+php-fpm，但不可用于线上生产环境。</div><div class="line">可以使用-t参数指定document_root，如果不指定表示使用当前目录作为document_root</div><div class="line">php -S 0.0.0.0:9000 -t /data/webroot/</div><div class="line">php -c</div><div class="line">指定加载php.ini的绝对路径</div><div class="line">php -c /home/htf/my_php.ini</div><div class="line">php <span class="_">-l</span></div><div class="line">检测一个php代码文件是否有语法错误，如 php <span class="_">-l</span> test.php</div><div class="line">php -r</div><div class="line">执行一段php代码，如</div><div class="line">php -r <span class="string">"echo 'hello world';"</span></div><div class="line">php --ini</div><div class="line">显示当前加载的php.ini绝对路径</div><div class="line">php --re swoole</div><div class="line">显示某个扩展提供了哪些类和函数。</div><div class="line">php --ri swoole</div><div class="line">显示扩展的phpinfo信息。与phpinfo的作用相同，不同之处是这里仅显示指定扩展的phpinfo</div><div class="line">php --rf file_get_contents</div><div class="line">显示某个PHP函数的信息，一般用于检测函数是否存在</div></pre></td></tr></table></figure>
<h3 id="Linux下查看一个端口被哪个占用进程"><a href="#Linux下查看一个端口被哪个占用进程" class="headerlink" title="Linux下查看一个端口被哪个占用进程"></a>Linux下查看一个端口被哪个占用进程</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">netstat -apn|grep 7782</div><div class="line">tcp        0      0 :::80                       :::*                        LISTEN      19408/java </div><div class="line">#那么进程号就是`19408`</div><div class="line">再通过`ps -ef | grep 19408` 就知道这个进程是啥了。</div><div class="line">+</div></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://blog.mango16.cc/2017/03/10/everyday/" data-id="cjrbtw1xw000m6d8h8fzkhblh"
         class="article-share-link">分享</a>
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/phper/">phper</a></li></ul>

    </footer>

  </div>

  
    
  <nav class="article-nav">
    
      <a href="/2017/04/12/Guzzle/" class="article-nav-link">
        <strong class="article-nav-caption">前一篇</strong>
        <div class="article-nav-title">
          
            利用Guzzle刷豆瓣热评引发的联想
          
        </div>
      </a>
    
    
      <a href="/2017/02/23/Decorator/" class="article-nav-link">
        <strong class="article-nav-caption">后一篇</strong>
        <div class="article-nav-title">PHP Decorator 装饰器模式</div>
      </a>
    
  </nav>


  

  
    
  <div class="gitalk" id="gitalk-container"></div>
  <link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
  <script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
  <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
  <script type="text/javascript">
      var gitalk = new Gitalk({
        clientID: 'caba8826a61790936307',
        clientSecret: '09a15037dcab30d9adf35a53ec6961939169f797',
        repo: 'm9rco.github.io',
        owner: 'm9rco',
        admin: ['m9rco'],
        // id: location.pathname,      // Ensure uniqueness and length less than 50
        id: md5(location.pathname),
        distractionFreeMode: false  // Facebook-like distraction free mode
      })

  gitalk.render('gitalk-container')
  </script>

  

</article>



</section>
  <footer class="footer">
  
  <div class="outer">
    <ul class="list-inline">
      <li>&copy; 2019 无敌小笼包</li>
      <i class="pulse"></i>
    </ul>
  </div>
</footer>

</main>
<aside class="sidebar">
  <button class="navbar-toggle"></button>

<nav class="navbar">
  
    <div class="logo">
      <a href="/"><img src="/images/hexo.svg" alt="无敌小笼包"></a>
    </div>
  
  <ul class="nav nav-main">
    
      <li class="nav-item">
        <a class="nav-item-link" href="/">主页</a>
      </li>
    
      <li class="nav-item">
        <a class="nav-item-link" href="/archives">归档</a>
      </li>
    
      <li class="nav-item">
        <a class="nav-item-link" href="/gallery">相册</a>
      </li>
    
      <li class="nav-item">
        <a class="nav-item-link" href="/nagging">叽咕</a>
      </li>
    
      <li class="nav-item">
        <a class="nav-item-link" href="/about">关于</a>
      </li>
    
    <li class="nav-item">
      <a class="nav-item-link nav-item-search" title="Search">
        <i class="fe fe-search"></i>
        搜索
      </a>
    </li>
  </ul>
</nav>

<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
        <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
          <i class="fe fe-feed"></i>
        </a>
      
    </li>
  </ul>
</nav>

<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
</aside>
  <script src="/js/jquery-2.0.3.min.js"></script>
<script src="/js/lazyload.min.js"></script>


  <script src="/fancybox/jquery.fancybox.min.js"></script>



  <script src="/js/search.js"></script>


<script src="/js/ocean.js"></script>

</body>
</html>